home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / Cookie / Source / CookieFileListView.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.2 KB  |  103 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "CookieFileListView.h"
  5. #import "ExportCell.h"
  6. #import <appkit/appkit.h>
  7. #import "CookieFile.h"
  8. #import <string.h>
  9. #undef ABS
  10. #import <c.h>
  11.  
  12. @implementation CookieFileListView
  13.  
  14. - (Matrix *)matrix
  15. {
  16.     return DocMatrix;
  17. }
  18.  
  19. - initFrame :(NXRect *)theFrame
  20. {
  21.     NXRect    scrollRect,matrixRect;
  22.     NXSize cellSize;
  23.  
  24.     [super initFrame:theFrame];
  25.  
  26.     // Set the scrollView's attributes
  27.     [self setBorderType:NX_BEZEL];
  28.     [self setVertScrollerRequired:YES];
  29.     [self setHorizScrollerRequired:NO];
  30.  
  31.     // get the scrollView's dimensions
  32.     [self getFrame:&scrollRect];
  33.  
  34.     // Determine the matrix bounds
  35.     [ScrollView getContentSize:&(matrixRect.size)
  36.             forFrameSize:&(scrollRect.size)
  37.         horizScroller:NO
  38.         vertScroller:YES
  39.         borderType:NX_BEZEL];
  40.  
  41.     // Prepare a Matrix to go inside our scrollView
  42.     DocMatrix = [[Matrix alloc] initFrame:&matrixRect
  43.         mode:NX_HIGHLIGHTMODE
  44.         cellClass:[ExportCell class]
  45.         numRows:0
  46.         numCols:1];
  47.     
  48.     // resize the matrix's cells and size the matrix to contain them
  49.     [DocMatrix getCellSize:&cellSize];
  50.     cellSize.width = NX_WIDTH(&matrixRect);
  51.     [DocMatrix setCellSize:&cellSize];
  52.     [DocMatrix sizeToCells];
  53.     [DocMatrix setAutosizeCells:YES];
  54.  
  55.     /*
  56.      * when the user clicks in the matrix and then drags the mouse out of
  57.      * scrollView's contentView, we want the matrix to scroll
  58.      */
  59.     [DocMatrix setAutoscroll:YES];
  60.  
  61.     // stick the matrix in our scrollview
  62.     [self setDocView:DocMatrix];
  63.  
  64.     // set things up so that the matrix will resize properly
  65.     [[DocMatrix superview] setAutoresizeSubviews:YES];
  66.     [DocMatrix setAutosizing:NX_WIDTHSIZABLE];
  67.  
  68.     return self;
  69. }
  70.  
  71. - syncView :(List *)mylist
  72. {
  73.     int count,maxcount = [mylist count];
  74.  
  75.     while([DocMatrix cellCount] < maxcount)
  76.         [DocMatrix addRow];
  77.  
  78.     while([DocMatrix cellCount] > maxcount)
  79.         [DocMatrix removeRowAt:0 andFree:TRUE];
  80.  
  81.     [DocMatrix sizeToCells];
  82.  
  83.     for(count = 0; count < maxcount; count++)
  84.     {
  85.         CookieFile *cookieFile = [mylist objectAt:count];
  86.         ExportCell *myCell;
  87.  
  88.         myCell = [DocMatrix cellAt:count:0];
  89.  
  90.         [myCell setTitle:[cookieFile filename]];
  91.         if([cookieFile selected])
  92.             [myCell setState:TRUE];
  93.         else
  94.             [myCell setState:FALSE];
  95.  
  96.         [DocMatrix drawCellAt :count :0];
  97.     }
  98.  
  99.     return self;
  100. }
  101.  
  102. @end
  103.